﻿namespace ConsoleApp2.Utils;

public static class UserInputUtils
{
    const int USER_LENGTH = 4;
    public static string CheckUserInputLength(string str, string name)
    {
        return CheckUserInputLength(str, name,USER_LENGTH);
    }
    private static string CheckUserInputLength(string str, string name,int length)
    {
        while (true)
        {
            if (str != null && str != "" && str.Length > length)
            {
                return str;
            }
            if (str == "" || str == null)
            {
                Console.WriteLine($"您输入的时候{name}为空，请重新输入");
            }

            if (str.Length < 5)
            {
                Console.WriteLine($"您输入的{name}的长度不能小于5位，请重新输入");
            }

            str = Console.ReadLine();
        }
    }
}